<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>layui</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="__static/lib/layui-v2.5.5/css/layui.css" media="all">
	<link rel="stylesheet" href="__static/css/public.css" media="all">
	<style>
		.layui-form-pane .layui-form-label {
			width: 90px;
		}
	</style>
</head>
<body>
<div class="layuimini-container">
	<div class="layuimini-main">
		<fieldset class="table-search-fieldset">
			<legend>搜索信息</legend>
			<form class="layui-form layui-form-pane" action="">
				<div class="layui-form-item" style="margin-bottom: 5px;">
					<div class="layui-inline">
						<div class="layui-input-inline">
							<select name="customer_id" lay-search="" autocomplete="off">
								<option value="" >直接选择客户名称</option>
								{volist name="kh_list" id="vo"}
									<option value="{$vo.id}" >{$vo.name}</option>
								{/volist}
					        </select>
						</div>
					</div>
					<div class="layui-inline">
						<div class="layui-input-inline">
							<select name="uid" lay-search="" autocomplete="off">
								<option value="" >直接选择运营名称</option>
								{volist name="User_list" id="vo"}
									<option value="{$vo.id}" >{$vo.username}</option>
								{/volist}
					        </select>
						</div>
					</div>
					<div class="layui-inline">
						<div class="layui-input-inline">
							<select name="mid" lay-search="" autocomplete="off">
								<option value="" >直接选择媒介名称</option>
								{volist name="m_list" id="vo"}
									<option value="{$vo.id}" >{$vo.username}</option>
								{/volist}
					        </select>
						</div>
					</div>
					<div class="layui-inline">
						<div class="layui-input-inline">
							<select name="op_account_id" lay-search="" autocomplete="off">
								<option value="" >0直接选择账户ID</option>
								{volist name="acc_list" id="vo"}
									<option value="{$vo.id}" >{$vo.name_id}</option>
								{/volist}
					        </select>
						</div>
					</div>
					<div class="layui-inline">
						<div class="layui-input-inline">
							<select name="is_operate" lay-search="" autocomplete="off">
								<option value="" >0直接选择运营类型</option>
								<option value="1" >自运营</option>
								<option value="2" >代运营</option>
					        </select>
						</div>
					</div>
					<div class="layui-inline">
						<div class="layui-input-inline">
							<select name="channel_id" lay-search="" autocomplete="off">
								<option value="" >0直接选端口</option>
								{volist name="cu_list" id="vo"}
									<option value="{$vo.id}" >{$vo.name}</option>
								{/volist}
					        </select>
						</div>
					</div>
					<div class="layui-inline">
						<div class="layui-input-inline">
							<input type="text" name="time" id="date" placeholder="请选择日期" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
					</div>
				</div>
			</form>
		</fieldset>
		<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
	</div>
</div>
<script src="__static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="__static/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="__static/js/man.js" charset="utf-8"></script>
<script>
	
	var form,table,laydate
	layui.use(['form', 'table', 'tableSelect', 'laydate'], function () {
		$ = layui.jquery , form = layui.form , table = layui.table , laydate = layui.laydate
		laydate.render({
		    elem: '#date' //指定元素
            ,range: '&'
		  });
		table.render({
			elem: '#currentTableId',
			height: 'full-150',
			id:'list_re_apply',
			url: '{:url("finance/consumes_list", ["t"=>"json"])}',
			method : 'post',
			toolbar: true,
            totalRow: true,
			cols: [[
                { field: 'time', title: '日期' ,width:120,templet:function(d){
					return d.time?date('Y-m-d',d.time):''
				}, totalRowText: '合计',fixed: 'left'}, 
				{ field: 'opaccount_name', title: '账户ID',width:180,fixed: 'left'},
				{ field: 'customer_name', title: '客户',width:180},
				{ field: 'channel_name', title: '端口',width:100},
				{ field: 'hy_name', title: '行业',width:100},
				{ field: 'currency', title: '消耗',width:100, totalRow: true,edit: 'text'},
				{ field: 'balance', title: '昨日结余',width:100, totalRow: true,edit: 'text'},
				{ field: 'channel_rebate', title: '端口点',width:120,edit: 'text'},
                { field: 'rebate', title: '客户点',width:120,edit: 'text'},
                { field: 'consume_profit', title: '消耗利润',width:120, totalRow: true,edit: 'text'},
				{ field: 'proof_url', title: '消耗凭证',width:180,templet:function(d){
					return d.proof_url?'<img src="'+d.proof_url+'">':''
				}},
				{ field: 'operate_name', title: '运营',width:180},
				{ field: 'media_name', title: '媒介',width:180},
				
                { field: 'is_operate', title: '运营类型',width:180,templet:function(d){
					return d.is_operate == 1?'自运营':'代运营'
				}},
				
			]],
			
			limit: 30,
			page: true,
			skin: 'line',
			
		});

		//监听行单击事件
		table.on('row(currentTableFilter)', function(obj){
			  layer.photos({
				  photos: obj.tr
				  ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
				});
			});
		
		
		//搜索
		form.on('submit(data-search-btn)', function(data){
			var articleFrom = data.field;
			table.reload('list_re_apply', {
			  	url: '{:url("finance/consumes_list", ["t"=>"json"])}',
				where:articleFrom
			});
			return false;
		});
		//监听单元格编辑
		table.on('edit(currentTableFilter)', function(obj){
			var value = obj.value //得到修改后的值
			,data = obj.data //得到所在行所有键值
			,field = obj.field; //得到字段
			
			var arr = new Array(data.id,value,field);
			get_save(arr);
		});
	});
	//重载数据表
	function get_apply(msg,n=6){
		table.reload('list_re_apply', {
			  url: '{:url("finance/consumes_list", ["t"=>"json"])}',
			});
		layer.msg(msg, {icon: n});
	}
	//修改
	function get_save(data){
		
		layer.load(1, { shade : [ 0.5, '#676a6c' ] }); 
		$.post("{:url('get_save')}?t=json",{data:data},function(da){
			layer.closeAll();
			if(da['code'] == 0){
				get_apply(da['msg'],5);
			}
		});
	}
</script>

</body>
</html>